<template>
  <el-card class="aside-tags" shadow="never">
    <div class="aside-tags-title">
      <i class="el-icon-third-biaoqian is-vertical iconfont-default" />
      <span class="aside-tags-title-text">标签</span>
    </div>
    <ul class="aside-tags-list">
      <li v-for="tag of tags" :key="tag.id" class="aside-tags-list-item">
        <router-link
          :to="{
            name: 'PublicPage',
            params: { menuName: 'tags', label: tag.name },
          }"
          class="tag-link"
          :style="{
            color: tag.color,
            fontSize: tag.weight / 100 + 'rem',
          }"
        >
          {{ tag.name }}
        </router-link>
      </li>
    </ul>
  </el-card>
</template>

<script>
import $api from "$api/tags";
export default {
  name: "AsideTags",
  data() {
    return {
      tags: [],
    };
  },
  mounted() {
    this.getTags();
  },
  methods: {
    getTags() {
      $api.getTags().then((res) => {
        if (res.status === 200) {
          this.tags = res.data;
        }
      });
    },
  },
};
</script>

<style lang="stylus" scoped>
.aside-tags-title-text {
  margin-left: 0.1rem;
}

.aside-tags-list {
  line-height: 2;
  margin-top: 0.1rem;
}

.aside-tags-list-item {
  padding: 0 0.03rem;
  display: inline-block;
}

.tag-link:hover {
  color: var(--colorLevel1) !important;
}
</style>